[アップデート] AWS Control CatalogでControl Towerの各コントールの内容を参照できる様になりました

[アップデート] AWS Control CatalogでControl Towerの各コントールの内容を参照できる様になりました

Clock Icon2024.08.08

しばたです。

先週ごろの話なのですが、AWS Control CatalogのAPIが更新されControl Towerの各コントールの内容を参照できる様になっています。
AWSからは先日アナウンスが出ました。

https://aws.amazon.com/jp/about-aws/whats-new/2024/08/aws-control-tower-new-descriptive-control-apis/

更新内容

こちらの詳細はAWS API Changesの更新を見てもらう方が分かりやすいでしょう。

https://awsapichanges.com/archive/changes/efb956-controlcatalog.html

AWS Control Catalog

  • ListControls
  • GetControl

の2つのAPIが増え、Control Towerで使われているコントールの一覧と各コントロールの内容を取得できます。
AWS CLIもVer.2.17.21から対応済みです。

  • api-change:controlcatalog: AWS Control Tower provides two new public APIs controlcatalog:ListControls and controlcatalog:GetControl under controlcatalog service namespace, which enable customers to programmatically retrieve control metadata of available controls.

AWS Control Catalogおさらい

AWS Control Catalogは今年の4月に増えたサービスで、Control Towerの一部としてコントロールに対するカタログ機能を提供するものになります。

https://dev.classmethod.jp/articles/new-service-aws-control-catalog/

リリース当時に提供されたDomainObjectiveCommon ControlはControl Towerの各コントールと紐づかない情報だったのですが、今回の更新でControl Towerの各コントロールの情報を直接取得できる様になりました。

また、AWS Control CatalogはControl Towerを導入していないアカウントでも使えます。

試してみた

今回は私の検証用AWSアカウントの東京リージョンのAWS CloudShellを使います。
AWS CLIのバージョンがVer.2.17.22だったので新APIに対応済みです。

AWS CloudShell
# AWS CLI Ver.2.17.22 で動作確認
$ aws --version 
aws-cli/2.17.22 Python/3.11.9 Linux/6.1.97-104.177.amzn2023.x86_64 exec-env/CloudShell exe/x86_64.amzn.2023

aws controlcatalog list-controls

コントロールの一覧を取得する際はaws controlcatalog list-controlsコマンドを使います。
実行結果は以下の通りで、各コントールのARN、名前、説明が取得できます。

# コントロールの一覧を取得
$ aws controlcatalog list-controls 
{
    "Controls": [
        {
            "Arn": "arn:aws:controlcatalog:::control/4b0nsxnd47747up54ytdqesxi",
            "Name": "Require any AWS CodeBuild project environment to have logging configured",
            "Description": "This control checks whether AWS CodeBuild projects environment has at least one logging option enabled."
        },
        {
            "Arn": "arn:aws:controlcatalog:::control/7rrde1yjxvdp8hyfina89c07z",
            "Name": "ECS containers should run as non-privileged",
            "Description": "This control checks if the privileged parameter in the container definition of Amazon ECS task definitions is set to 'true'. This control fails if this parameter is equal to 'true'."
        },
        {
            "Arn": "arn:aws:controlcatalog:::control/8cclsjiy1o81kfsmzpt85nbjk",
            "Name": "Disallow changes to Amazon CloudWatch Logs log groups set up by AWS Control Tower",
            "Description": "Prevent deletion and modification of retention policy for Amazon CloudWatch Logs log groups set up by AWS Control Tower."
        },
        #
        # ・・・中略・・・
        #
        {
            "Arn": "arn:aws:controlcatalog:::control/1z2biltzuotpq1tha9ruwwh2g",
            "Name": "Unused Network Access Control Lists should be removed",
            "Description": "This control checks to see if there are any NACLs (Network Access Control List) that are unused. The control will check the item configuration of the resource AWS::EC2::NetworkAcl and determine the relationships of the NACL."
        },
        {
            "Arn": "arn:aws:controlcatalog:::control/9q95fgqyj5tqodrep7z08fn3",
            "Name": "ECS services should not have public IP addresses assigned to them automatically",
            "Description": "This control checks whether ECS services are configured to automatically assign public IP addresses. This control fails if AssignPublicIP is ENABLED."
        }
    ]
}

aws controlcatalog get-control

各コントールの詳細を取得するにはaws controlcatalog get-controlコマンドを使います。
--control-arnパラメーターで対象コントロールのARNを指定して使います。

結果は以下の通り、対象コントロールの基本情報の他に「動作」と「デプロイ可能リージョン」を取得できます。

# 特定コントロールの情報を取得
$ aws controlcatalog get-control --control-arn arn:aws:controlcatalog:::control/4b0nsxnd47747up54ytdqesxi
{
    "Arn": "arn:aws:controlcatalog:::control/4b0nsxnd47747up54ytdqesxi",
    "Name": "Require any AWS CodeBuild project environment to have logging configured",
    "Description": "This control checks whether AWS CodeBuild projects environment has at least one logging option enabled.",
    "Behavior": "PROACTIVE",
    "RegionConfiguration": {
        "Scope": "REGIONAL",
        "DeployableRegions": [
            "af-south-1",
            "ap-east-1",
            "ap-northeast-1",
            "ap-northeast-2",
            "ap-northeast-3",
            "ap-south-1",
            "ap-south-2",
            "ap-southeast-1",
            "ap-southeast-2",
            "ap-southeast-3",
            "ap-southeast-4",
            "ca-central-1",
            "ca-west-1",
            "eu-central-1",
            "eu-central-2",
            "eu-north-1",
            "eu-south-1",
            "eu-south-2",
            "eu-west-1",
            "eu-west-2",
            "eu-west-3",
            "il-central-1",
            "me-central-1",
            "me-south-1",
            "sa-east-1",
            "us-east-1",
            "us-east-2",
            "us-west-1",
            "us-west-2"
        ]
    }
}

取得できる言語は英語だけの様で、マネジメントコンソール[1]上の表記(日本語等)と付け合わせるのは少し手間がかかる感じでした。
(マネジメントコンソールの検索条件にARNが欲しい...)

aws-control-tower-new-descriptive-control-apis-01

aws-control-tower-new-descriptive-control-apis-02

詳細を確認するとARNがarn:aws:controlcatalog:::control/4b0nsxnd47747up54ytdqesxiであることも確認でき、デプロイ可能リージョンの内容も一致しています。

aws-control-tower-new-descriptive-control-apis-03

最後に

簡単ですが以上となります。

現時点では取得できる情報が少ないのですが、AWSとしては自動化を意図したAPIの公開とのことですので順次増えるのではないかと予想します。今後に期待したいですね。

AWS Control CatalogはControw Towerを利用していないアカウントでも使えるサービスですので気軽に試してみると良いでしょう。

脚注
  1. こちらはContorl Towerを有効化した別アカウントで確認しています ↩︎

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.